<?php

use think\migration\Seeder;

class AddBaseSupplier extends Seeder
{

    public $jutuike_secret = 'RPFXiLSND5xcDyb57uJvT0XcgJmyfEWi';//非公司密钥
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    public function run()
    {

        if (env('APP_ENV') != 'local'){
            echo '非测试环境'.PHP_EOL;
            return true;
        }



        $objs = [];
        //添加测试的密钥
         $objs[] = \app\model\BaseSupplier::findOrNew([
            'code' => 'jutuike',
            'serv_type' => PRODUCT_AROUND_SHOP_SERV //周边游
        ]);
        $objs[] = \app\model\BaseSupplier::findOrNew([
            'code' => 'jutuike',
            'serv_type' => PRODUCT_FOOD_SHOP_SERV //餐饮
        ]);


        foreach ($objs as $obj) {

            /**
             * @var \app\model\BaseSupplier $obj
             */

            if (!empty($obj->id)){
                continue;
            }

            $obj->api_config = [
                'apikey' => $this->jutuike_secret
            ];
            $obj->name = PRODUCT_SERV_TYPE[$obj->serv_type]['name'].'-系统自动生成';

            $obj->save();


        }



    }
}